<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j"
    template="layout/template.xhtml">

<ui:define name="body">
	
	<h2 class="title"><a href="#">Gerenciar Pacotes</a></h2><br/>

            <h:form id="pacoteForm">
            
			           <h:panelGrid columns="1">
			            	<s:decorate template="/layout/edit.xhtml">
			            		<ui:define name="label">Cliente:</ui:define>
			            		<a:region>
				            		<h:selectOneMenu value="#{manterPacoteController.clienteSelecionado}"
				            			required="true">
				            			<f:selectItems value="#{manterPacoteController.listaClientes}"/>
				            			<a:support event="onchange" action="#{manterPacoteController.buscarOutrasInformacoes()}" 
				            				reRender="gridDadosContrato"/>
				            		</h:selectOneMenu>
			            		</a:region>
			            	</s:decorate>

			            	<s:decorate template="/layout/edit.xhtml">
			            		<ui:define name="label">Data do Pagamento:</ui:define>
			            		<rich:calendar value="#{manterPacoteController.pacoteEdicao.dtaPagamento}"
			            			datePattern="dd/MM/yyyy"
			            			required="false">
			            		</rich:calendar>
			            	</s:decorate>
			            	
			            	<s:decorate template="/layout/edit.xhtml">
			            		<ui:define name="label">Data Início:</ui:define>
			            		<rich:calendar value="#{manterPacoteController.pacoteEdicao.dtaInicio}"
			            			datePattern="dd/MM/yyyy"
			            			required="true"/>
			            	</s:decorate>
			            	
			            	<s:decorate template="/layout/edit.xhtml">
			            		<ui:define name="label">Data Fim:</ui:define>
			            		<rich:calendar value="#{manterPacoteController.pacoteEdicao.dtaFim}"
			            			datePattern="dd/MM/yyyy"
			            			required="true">
			            		</rich:calendar>
			            	</s:decorate>
			            	
			            	<s:decorate template="/layout/edit.xhtml">
			            		<ui:define name="label">Forma de pagamento:</ui:define>
			            		<h:selectOneMenu value="#{manterPacoteController.idFormaPagamento}">
			            			<f:selectItems value="#{manterPacoteController.listaFormasPagamento}"/>
			            		</h:selectOneMenu>
		            		</s:decorate>
			            	
			            	<s:decorate template="/layout/edit.xhtml">
			            		<ui:define name="label">Valor:</ui:define>
			            		<h:inputText value="#{manterPacoteController.pacoteEdicao.vlrPacote}"
			            			required="true"
			            			onkeydown="Mascara(this,Valor);"
			            			onkeyup="Mascara(this,Valor);"
			            			converter="conversorMonetario"/>
			            	</s:decorate>
			            	
			            	<s:decorate template="/layout/edit.xhtml">
			            		<ui:define name="label">Observações:</ui:define>
			            		<h:inputTextarea value="#{manterPacoteController.pacoteEdicao.dscObservacao}"
			            			cols="50" rows="5"/>
			            	</s:decorate>
			            </h:panelGrid>
			            
			            <fieldset>
			            	<legend>Dados do contrato</legend>
				            <h:panelGrid columns="1" id="gridDadosContrato">
				        		
				        		<s:decorate template="/layout/edit.xhtml">
			            			<ui:define name="label">Dia do pagamento:</ui:define>
			            			<h:inputText value="#{manterPacoteController.pacoteEdicao.diaPagamentoMes}"
			            				onkeydown="Mascara(this,Integer)"
				            			onkeyup="Mascara(this,Integer)" 
				            			style="width: 20px;"
				            			maxlength="2"/>
			            		</s:decorate>
			            		    	
				        		<s:decorate template="/layout/edit.xhtml">
			            			<ui:define name="label">CPF:</ui:define>
			            			<h:inputText value="#{manterPacoteController.pacoteEdicao.dscCpf}"
			            				onkeydown="Mascara(this,Cpf)"
				            			onkeyup="Mascara(this,Cpf)" 
				            			style="width: 100px;"
				            			maxlength="14"
				            			converter="conversorCPF"/>
			            		</s:decorate>    	
			            		
			            		<s:decorate template="/layout/edit.xhtml">
			            			<ui:define name="label">RG:</ui:define>
			            			<h:inputText value="#{manterPacoteController.pacoteEdicao.dscRg}"
			            				onkeydown="Mascara(this,Integer)"
				            			onkeyup="Mascara(this,Integer)" 
				            			style="width: 100px;"
				            			maxlength="20"/>
			            		</s:decorate>
			            		
			            		<s:decorate template="/layout/edit.xhtml">
			            			<ui:define name="label">Órgão Expedidor:</ui:define>
			            			<h:inputText value="#{manterPacoteController.pacoteEdicao.dscOrgaoExpRg}"
				            			style="width: 100px;"
				            			maxlength="20"/>
			            		</s:decorate>
			            		
			            		<s:decorate template="/layout/edit.xhtml">
			            			<ui:define name="label">UF do Endereço:</ui:define>
			            			<h:inputText value="#{manterPacoteController.pacoteEdicao.dscUfEndereco}"
				            			style="width: 20px;"
				            			maxlength="2"/>
			            		</s:decorate>
				            </h:panelGrid>
			            </fieldset>
	            
	            <br/>
	            <div class="actionButtons">
		        	<h:commandButton id="submit" value="Salvar" action="#{manterPacoteController.salvar}"
		            	onclick="javascript:if(!confirm('Tem certeza que deseja salvar?'))return false;"/>
		            	
		            <h:commandButton id="cancel" value="Cancelar" 
				        		action="#{manterPacoteController.cancelar}" 
				        		immediate="true"/>
		        </div>
				<br/>
				
			</h:form>
			
 </ui:define>
</ui:composition>
